package com.swh.controller.system;

import com.github.pagehelper.PageInfo;
import com.swh.entity.QualificationCondition;
import com.swh.entity.SysResource;
import com.swh.service.SysResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/28 16:21
 * @Version: 1.0
 */
@Controller
@RequestMapping("/guguanjia/resource")
public class SysResourceController {
    @Autowired
    private SysResourceService service;

    @RequestMapping("/index")
    public String login() {
        return "/menu/menu";
    }

    @RequestMapping("/toUpdate")
    public String toUpdate() {
        return "/menu/menu-save";
    }

    @RequestMapping("/detail")
    public String detail() {
        return "/menu/menu-detail";
    }

    @RequestMapping("toSelect")
    public String toSelect() {
        return "menu/menu-select";
    }

    @ResponseBody
    @RequestMapping("/selectPage/{pageNum}/{pageSize}")
    public PageInfo<Map> selectPage(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize,
                                    QualificationCondition condition) {
        return service.selectPage(pageNum, pageSize, condition);
    }


    //修改
    @ResponseBody
    @RequestMapping(value = "/updateById", method = RequestMethod.POST)
    public void updateById(@RequestBody SysResource sysResource) {
        sysResource.setUpdateDate(new Date());
        service.update(sysResource);
    }

    @ResponseBody
    @RequestMapping("/findAll")
    public List<SysResource> findAll() {
        return service.findAll();
    }



    //根据id查询并且回写数据
    @ResponseBody
    @RequestMapping("/get")
    public Object get(Integer id) {
        return service.findById(id);

    }


}
